package io.renren.modules.generator.service.impl;

import io.renren.common.utils.*;
import io.renren.modules.generator.entity.TTrainingObjectEntity;
import io.renren.modules.generator.entity.vo.TTrainingScoreVo;
import io.renren.modules.generator.entity.vo.UpdateScoreVo;
import io.renren.modules.user.entity.TPeopleEntity;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.generator.dao.TTrainingScoreDao;
import io.renren.modules.generator.entity.TTrainingScoreEntity;
import io.renren.modules.generator.service.TTrainingScoreService;
import org.springframework.web.multipart.MultipartFile;


@Service("tTrainingScoreService")
public class TTrainingScoreServiceImpl extends ServiceImpl<TTrainingScoreDao, TTrainingScoreEntity> implements TTrainingScoreService {

    @Autowired
    private TTrainingScoreDao trainingScoreDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TTrainingScoreEntity> page = this.page(
                new Query<TTrainingScoreEntity>().getPage(params),
                new QueryWrapper<TTrainingScoreEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 历史成绩列表
     */
    public List<TTrainingScoreEntity> getTTrainingScore(TTrainingScoreEntity trainingScoreEntity){
        return trainingScoreDao.getTTrainingScore(trainingScoreEntity);
    }
    /**
     * 最新成绩列表
     */
    public List<TTrainingScoreEntity> selectList(TTrainingScoreEntity queryWrapper){
        return trainingScoreDao.selectList(queryWrapper);
    }

    /**
     * 导入
     */
    @Override
    public Boolean DrTTrainingScore(List<TTrainingScoreVo> list){
        return trainingScoreDao.DrTTrainingScore(list);
    }

    /**
     * 根据身份证号  获取人员id
     * @param peopleEntity
     * @return
     */
    public TPeopleEntity getPeopleId(TPeopleEntity peopleEntity){
        return trainingScoreDao.getPeopleId(peopleEntity);
    }

    /**
     * 自动评分 测试
     */
   public List<TTrainingScoreEntity> automaticScoring(TTrainingScoreEntity trainingScoreEntity){
        return trainingScoreDao.automaticScoring(trainingScoreEntity);
    }
    /**
     * 批量修改  自动评分后 将成绩填入对应的行（人）
     */
   public int updatePlScore(List<UpdateScoreVo> UpdateScoreList){
        return trainingScoreDao.updatePlScore(UpdateScoreList);
    }

    /**
     * 批量修改  自动评分后 将成绩和评价填入对应的行（人）
     */
    public int updateMarkAndjudge(List<TTrainingScoreEntity> list){
        return trainingScoreDao.updateMarkAndjudge(list);
    }
    /**
     * 单个修改  自动评分后 将成绩和评价填入对应的行（人）
     */
    public int updateMarkAndjudgeSingle(TTrainingScoreEntity tTrainingScoreEntity){
        return trainingScoreDao.updateMarkAndjudgeSingle(tTrainingScoreEntity);
    }
    /**
     * 获取自动评分后 的合格率
     */
   public Double getHgl(TTrainingScoreEntity trainingScoreEntity){
       return trainingScoreDao.getHgl(trainingScoreEntity);
    }

    /**
     * 判定 类型
     */
   public List<Map<String,Object>> decideList(){
        return  trainingScoreDao.decideList();
    }
    /**
     * 获取单次训练成绩
     */
    public List<TTrainingScoreEntity> selectByTrainingIdAndChenkCount(Integer trainingId,Integer chenkCount){
        return trainingScoreDao.selectByTrainingIdAndChenkCount(trainingId,chenkCount);
    }

    public List<Map<String,Object>> batchGetPeopleId( List<String> idNoList){
        return trainingScoreDao.batchGetPeopleId(idNoList);
    }

    public Map<String,Object> selectPeople(Integer id){
        return trainingScoreDao.selectPeople(id);
    }
}